import store from '../store/index'
const checkLogin =
  function (cbUrl) {
    const authUserInfo = store.state.userInfo;
    let { nick_name, mobile } = authUserInfo
    if (!nick_name) {
      if (cbUrl) {
        let url = "/pages/login/loginUserinfo?cbUrl=" + encodeURIComponent(cbUrl)
        if (cbUrl === '/pages/coupon/coupon') {
          uni.redirectTo({
            url
          });
        } else {
          uni.navigateTo({
            url
          });
        }
      }

      return false;
    } else {
      if (!mobile) {
        if (cbUrl) {
          uni.navigateTo({
            url: "/pages/login/loginIndex?cbUrl=" + encodeURIComponent(cbUrl),
          });
        }
        return false;
      } else {
        if (cbUrl) {
          uni.navigateTo({
            url: cbUrl,
          });
        }
        return true;
      }
    }
  }
export default checkLogin;
